// JavaScript Document
var SiteMain = (function() {
	function init(){
		setBG();
		//slider.init();
		continue_step2();
		home.init();
		slider_bottom.init();
		hoverMenu();
		createRating();
		createSlide();
	}
	
	function createSlide(){
		var bdrap = true;
		$("#uneven_slider").touchme({
			preventDefaultEvents: false,
			isDetectHorizontalMovement:true,
			isDetectVecticalMovement:true,
			isDetectDiagonalMovement:true,
			wipeLeft: function(target) {
				$('.uneven').slickNext();
			},
			wipeRight: function(target) {
				$('.uneven').slickPrev();
			}
		}); 
		
		bdrap = false;
		$('.uneven').slick({
		  infinite: true,
		   speed: 1000,
		    autoplay: true,
			autoplaySpeed: 3000,
		  slidesToShow: 5,
		  slidesToScroll: 5,
		  swipe:bdrap,
		  draggable:true,
		  responsive: [
		    {
		      breakpoint: 1150,
		      settings: {
		        slidesToShow: 4,
		        slidesToScroll:4
		      }
		    },
		    {
		      breakpoint: 768,
		      settings: {
		        slidesToShow: 3,
		        slidesToScroll:3
		      }
		    },
		   
		  ]
		});
	}
	function createRating(){
		/*Rating 1*/
		$('#rating-1').rating({
              min: 0,
              max: 5,
              step: 1,
              size: 'lg'
        });
       
        $('#rating-1').on('rating.change', function() {
            console.log($('#rating-1').val());
        });
        
        /*Rating 2*/
        $('#rating-2').rating({
              min: 0,
              max: 5,
              step: 1,
              size: 'lg'
        });
       
        $('#rating-2').on('rating.change', function() {
            console.log($('#rating-2').val());
        });
        
        /*Rating 3*/
        $('#rating-3').rating({
              min: 0,
              max: 5,
              step: 1,
              size: 'lg'
        });
       
        $('#rating-3').on('rating.change', function() {
            console.log($('#rating-3').val());
        });
        
        /*Rating 4*/
        $('#rating-4').rating({
              min: 0,
              max: 5,
              step: 1,
              size: 'lg'
        });
       
        $('#rating-4').on('rating.change', function() {
            console.log($('#rating-4').val());
        });
        
        /*Rating 2*/
        $('#rating-5').rating({
              min: 0,
              max: 5,
              step: 1,
              size: 'lg'
        });
       
        $('#rating-5').on('rating.change', function() {
            console.log($('#rating-5').val());
        });
	}
	function setBG(){
		$('.menu ul li').each(function(){
			var color = $(this).attr('color');
			$(this).css('background','#'+color);
		});
		$('ul.li-page5 li').each(function(){
			var color = $(this).attr('bg');
			$(this).css('background','#'+color);
		});
	}
	
	
	function hoverMenu(){
		$('.commonPage .box-left ul.main-menu li').hover(function(){
			var color = $(this).attr('color');
			if($(this).hasClass('has-sub')){
				$(this).css({'background':'url("images/arrow.png") no-repeat scroll 145px center #' + color});
			}else{
				$(this).css({'background':'#' + color});
			}
		},function(){
			$(this).removeAttr('style');
		});
		
		$('.commonPage .box-left ul.main-menu li ul.sub li').hover(function(){
			var color = $(this).parent().parent().attr('color');
			if($(this).hasClass('has-sub')){
				$(this).css({'background':'url("images/arrow.png") no-repeat scroll 180px center #' + color});
			}else{
				$(this).css({'background':'#' + color});
			}
		},function(){
			$(this).removeAttr('style');
		});
		
		$('.commonPage .box-left ul.main-menu li ul.sub li ul.sub li').hover(function(){
			var color = $(this).parent().parent().parent().parent().attr('color');
			$(this).css({'background':'#' + color});
		},function(){
			$(this).removeAttr('style');
		});
	}
	
	function continue_step2(){
		$('#continue-step2').click(function(){
			var step = $(this).attr('step');
			$('.type-info .steps .step').removeClass('active');
			$("#"+step).addClass('active');
			$('.type-info .step-form .step-left .step').css({'display':'none'});
			$('.type-info .step-form .step-left .step.'+step).css({'display':'block'});
			return false;
		});
	}
	return {
		init:init
	}
})();		

$(document).ready( function() {
	SiteMain.init();
});

